package cn.chencaiju.day02;

public class FlowControllerTest4 {
	public static void main(String[] args) {
		firstTest(Integer.parseInt(args[0]));
		secondTest();
		thirdTest();
	}
	public static boolean firstTest(int x) {
		if(x<3) {
			//System.out.println("");
			return true;
		}
		int y=(int) Math.sqrt(x)+1;
		for(int i=2;i<=y;i++) {
			if(x%i==0) {
				//System.out.printf("x=%d不是素数",x);
				return false;
			}
		}
		//System.out.printf("x=%d是素数",x);
		return true;		
	}
	public static void secondTest() {
		System.out.println("\n100以内的素数有：");
		int count=0;
		for(int i=2;i<=100;i++) {
			if(firstTest(i)) {
				System.out.print(i+"\t");
				count++;
				if(count%5==0)
					System.out.println();
			}
		}		
	}
	public static void thirdTest() {
		int count=0;
		System.out.println();
		for(int i=2;count<50;i++) {
			if(firstTest(i)) {
				System.out.print(i+"\t");
				count++;
				if(count%5==0)
					System.out.println();
			}
		}		
	}

}
